import org.junit.Test;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/3/25 13:41
 * 杨辉三角形变形
 * 计算某字符出现的次数
 */
public class Day17 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String c =scanner.nextLine();

        System.out.println(countChar(s, c));
    }
    //----------------------------------------------------------
    public static int countChar(String s ,String ch){
        int count  =0 ;
        ch = ch.toLowerCase();
        char c = ch.toCharArray()[0];
        s = s.toLowerCase();
        for (int i = 0; i < s.length(); i++) {
            if (s.toCharArray()[i] == c ){
                count++;
            }
        }
        return count;
    }
    //----------------------------------------------------------
    public  static int solution1(int n){
        if (n==0 || n==1 || n==2){
            return -1;
        }
        int newNum = n-2;
        if (newNum %4==1 || newNum %4 ==3){
            return 2;
        }else if (newNum %4 ==2){
            return 3;
        }else {
            return 4;
        }

    }
    public  static int solution(int n){ //会溢出
        if (n==0 || n==1 || n==2){
            return -1;
        }
        long[][] arr = new long[n][2*n-1];
        arr[0][0]=1;
        arr[1][0]=1;
        arr[1][1]=1;
        arr[1][2]=1;
        long left = 0;
        long right = 0;
        long mid = 0;
        for (int row = 2; row < n; row++) {
            for (int col = 0; col < 2*row+1; col++) {
                if (col-2<0){
                    left = 0;
                }else{
                    left = arr[row-1][col-2];
                }
                if (col-1<0){
                    mid = 0;
                }else{
                    mid =arr[row-1][col-1];
                }
                if (col<0){
                    right = 0;
                }else{
                    right = arr[row-1][col];
                }
                arr[row][col]= left+mid +right;
            }

        }
        for (int i = 0; i < 2*n-1; i++) {
            if (arr[n-1][i] %2 ==0){
                return i+1;
            }
        }
        return -1;
    }
}
